package com.zzw.mvvm;

import android.app.Application;
import android.content.res.Configuration;
import android.content.res.Resources;

import com.zzw.mvvm.utils.AppUtils;
import com.zzw.mvvm.utils.Utils;

/**
 * auth zzw
 * 2019 03 18
 */
public class ApplicationMine extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        ourInstance = this;
        initComponents();
    }

    //字体不随系统改变
    @Override
    public Resources getResources() {
        Resources resources = super.getResources();
        if (resources.getConfiguration().fontScale != 1) {
            Configuration newConfig = new Configuration();
            newConfig.setToDefaults();
            resources.updateConfiguration(newConfig, resources.getDisplayMetrics());
        }
        return resources;
    }

    private void initComponents() {
        initBugly();
        Utils.init(this);

    }

    private boolean inMainProcess() {
        String packageName = getPackageName();
        String processName = AppUtils.getProcessName();
        return packageName.equals(processName);
    }

    private void initBugly() {
        // CrashReport.setIsDevelopmentDevice(this, Constants.DEBUG);
        // CrashReport.initCrashReport(this, Constants.APPID_BUGLY, Constants.DEBUG);
    }


    private static ApplicationMine ourInstance;

    public static ApplicationMine getInstance() {
        return ourInstance;
    }

}
